<?
//引入所有子系统信息
include_once("../../../common/model/extender_import.php");
//引入系统设置
include_once("../../../common/model/setting.php");



//获取板块的设置
include_once("model/setting.php");


//获取员工信息
$employee=select_one_line_all_items($table_Prefix."employee","nid = '".$_REQUEST['nid']."' ");



$unit_contactor=select_lines_all_items($table_Prefix."member","nid desc","agentnid = '".$_REQUEST['nid']."'","");



$member_contact_log=select_lines_all_items($table_Prefix."member_contact_log","nid desc","","20");







//获取默认的邮箱设置
$setting=select_one_line_all_items($table_prefix."setting_email","nid > 0");
if(!file_exists(ROOT_PATH_."/uploadfiles/".$_unit[$_SESSION['unit']]['uploadfile']."/employee/"))
{
    mkdir(ROOT_PATH_."/uploadfiles/".$_unit[$_SESSION['unit']]['uploadfile']."/employee",0777,true);
    chmod(ROOT_PATH_."/uploadfiles/".$_unit[$_SESSION['unit']]['uploadfile']."/employee",0777);
}


//http://yitong.enpingshi.com/api/binding_wechat_and_employee.php?p=9@circledesign


//判断一下员工绑定二维码是否存在，不存在就生成。
//员工二维码时  employee/{emloyeenid}.png
//为员工生成绑定二维码
if(!file_exists(ROOT_PATH_."/uploadfiles/". $_unit[$_SESSION['unit']]['uploadfile']."/employee/".$employee['nid'].".png"))
{
    //echo "不存在";
    $parma['url']  = "http://yitong.zhihuitiangong.com/api/binding_wechat_and_employee.php?p=".$employee['nid']."@".$_SESSION['unit'];
    $parma['name'] = $employee['nid'];
    $parma['local'] = ROOT_PATH_."/uploadfiles/". $_unit[$_SESSION['unit']]['uploadfile']."/employee/";

    $result=creat_qrcode($parma);
    //print_r2($result);

}
else
{
    $bind_code="";
}
























//整理一下时间参数
    $starttime=$_REQUEST['select_startday'];
    $endtime=$_REQUEST['select_endday'];
    
    
    if($starttime)
    {
        //搜索语句需要判断时间大于开始时间
        $starttime_sql=" and count_date >='".$starttime."' ";
    }
    if($endtime)
    {
        //搜索语句需要判断时间小于等于结束时间
        $endtime_sql=" and count_date <='".$endtime."' ";
    }
    
 
    
$case_list=select_lines_all_items($table_Prefix."case","count_date desc","1=1 ".$starttime_sql.$endtime_sql." and sales = '".$_REQUEST['nid']."'","");



//获取本页用到的单位的名字
$unit_nid_list=transform_2darray_in_1darray_with_new_key($case_list,"nid","unit");
$unit_nid_list_str=implode("','",$unit_nid_list);
$unit_list=select_lines_all_items($table_Prefix."unit","","nid in ('".$unit_nid_list_str."')","");
$unit_name_list=transform_2darray_in_1darray_with_new_key($unit_list,"nid","sname");




?>








